package com.ztools.pc.async;

import com.ztools.common.util.common.RedisHelper;
import com.ztools.common.util.pc.RedisUtil;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.nio.charset.StandardCharsets;

/**
 * @Author:一口香菜
 * @Date: 2023/3/15  20:32
 * @Version 1.0
 */
@Async
@Component
public class RedisAsync {

    @Resource
    private RedisHelper redisHelper;

    @Async
    public void doAfterPermissionChange() {
        redisHelper.scan(RedisUtil.PERMISSIONS + "*", item -> {
            String key = new String(item, StandardCharsets.UTF_8);
            redisHelper.delete(key);
        });
    }

}
